home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / sbin / cryptdisks_start < prev    next >
Encoding:
Text File  |  2011-03-11  |  1.1 KB  |  49 lines

  1. #!/bin/sh
  2.  
  3. # cryptdisks_start - wrapper around cryptsetup which parses
  4. # /etc/crypttab, just like mount parses /etc/fstab.
  5.  
  6. # Initial code and (c) 2007 Jon Dowland <jon@alcopop.org>
  7. # License: GNU General Public License, v2 or any later
  8. # (http://www.gnu.org/copyleft/gpl.html)
  9.  
  10. set -e
  11.  
  12. if [ $# -lt 1 ]; then
  13.     echo "usage: $0 <name>" >&2
  14.     echo >&2
  15.     echo "reads /etc/crypttab and starts the mapping corresponding to <name>" >&2
  16.     exit 1
  17. fi
  18.  
  19. . /lib/cryptsetup/cryptdisks.functions
  20.  
  21. INITSTATE="manual"
  22. DEFAULT_LOUD="yes"
  23.  
  24. if [ -x "/usr/bin/id" ] && [ "$(/usr/bin/id -u)"  != "0" ]; then
  25.     log_warning_msg "$0 needs root privileges"
  26.     exit 1
  27. fi
  28.  
  29. log_action_begin_msg "Starting crypto disk"
  30. mount_fs
  31.  
  32. count=0
  33. tablen="$(egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | /usr/bin/wc -l)"
  34. egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | while read dst src key opts; do
  35.     count=$(( $count + 1 ))
  36.     if [ "$1" = "$dst" ]; then
  37.         ret=0
  38.         handle_crypttab_line_start "$dst" "$src" "$key" "$opts" <&3 || ret=$?
  39.     elif [ $count -ge $tablen ]; then
  40.         ret=1
  41.         device_msg "$1" "failed, not found in crypttab"
  42.     else
  43.         continue
  44.     fi
  45.     umount_fs
  46.     log_action_end_msg $ret
  47.     exit $ret
  48. done 3<&1
  49.